//
//  InNavController.m
//  Inner  Voice
//
//  Created by brother on 16/3/1.
//  Copyright © 2016年 徐海宇. All rights reserved.
//

#import "InNavController.h"

#import "UIBarButtonItem+CustomItem.h"

#import "AppDelegate.h"

@interface InNavController ()

@end

@implementation InNavController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
// 重写系统的push方法
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
        // 自定义每个页面的NatiItem导航栏的返回按钮
        UIBarButtonItem *backBarItem = [UIBarButtonItem customBarButtonItemWithImageName:@"music_return" hightImageName:@"music_return" target:self selector:@selector(backClick)];
        
        viewController.navigationItem.leftBarButtonItem = backBarItem;
        
        UIBarButtonItem *homeBackBarItem = [UIBarButtonItem customBarButtonItemWithImageName:@"music_play" hightImageName:@"music_play" target:self selector:@selector(started)];
        viewController.navigationItem.rightBarButtonItem = homeBackBarItem;
    }
    [super pushViewController:viewController animated:animated];
}

- (void)backClick {
    [self popViewControllerAnimated:YES];
}

- (void)started {
    [self presentViewController:((AppDelegate *)[[UIApplication sharedApplication]delegate]).InPlayerViewController animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
